<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
//订单详情
if($_RQ['op']=='main'){
	if(!$_RQ['id']){
		exi('请选择考卷','error');
	}
	$item=pdo_get('jy_lineks_list',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	$return['item']=$item;	
	$params=array('uniacid'=>$_SESSION['uniacid'],'issub'=>1);
	if($_RQ['mid']){
		$params['mid']=$_RQ['mid'];
		$return['params']['mid']=$_RQ['mid'];
	}
	if($_RQ['id']){
		$params['datiid']=$_RQ['id'];
		$return['params']['id']=$_RQ['id'];
	}
	if($_RQ['dayid']){
		$params['dayid']=$_RQ['dayid'];
		$return['params']['dayid']=$_RQ['dayid'];
	}
	$list=pdo_getall('jy_lineks_canyu',$params,$fields,'','score desc,istime asc');
	if($list){
		$nowyear=date('Y');
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['nickname']=$item['member']['nickname'];
			$item['starttime']=$item['starttime']?:$item['createtime'];
			if($item['endtime']){
				$item['istime']=$item['endtime']-$item['starttime'];
				if($item['istime']>60){
					$item['istimefen']=intval($item['istime']/60);
					$item['istimemin']=$item['istime']-$item['istimefen']*60;
				}else{
					$item['istimefen']=0;
					$item['istimemin']=$item['istime'];
				}
				$item['istimeinfo']=$item['istimefen'].'分钟'.$item['istimemin'].'秒';
			}
			$item['datatitle']=pdo_getcolumn('jy_lineks_list',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['datiid']),'title');
			$item['starttime']=date('Y-m-d H:i:s', $item['starttime']);
			$item['endtime']=date('Y-m-d H:i:s', $item['endtime']);
			$birth=pdo_getcolumn('jy_lineks_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']),'birth');
			$birth=json_decode($birth,true);
			$item['birth']=$birth['year'].'-'.$birth['month'].'-'.$birth['day'];
			if($birth['year']){
				$item['age']=$nowyear-$birth['year'];
			}
			$user_name=$item['name'];
			$length = mb_strlen($user_name, 'utf-8');
			$firstStr = mb_substr($user_name, 0, 1, 'utf-8');
			$lastStr = mb_substr($user_name, -1, 1, 'utf-8');
			if($length ==1){
				$item['name']=$user_name;
			}
			$repeatStr = '*';
			$item['name']=$length == 2 ? $firstStr . str_repeat($repeatStr, $length - 1) : $firstStr . str_repeat($repeatStr, $length - 2) . $lastStr;
			$mobile1=substr($item['mobile'],0,3);
			$mobile2=substr($item['mobile'],-4);
			$item['mobile']=$mobile1.'****'.$mobile2;
		}
	}
	foreach($list as $k=>&$nv){
			$nv['key']=$nv['rank']=$k+1;
	}
	$return['list']=$list;
	exi($return);
}